<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/9 0009
 * Time: 11:08
 */

namespace app\wap\controller;
use think\Db;


class Seasonpush  extends  Base
{
        public function index(){
            $where['is_show']=1;
            $where['sign']='mobile';
            $where['is_del']=0;
            $data = Db::name('hxzp')->where($where)->order('sort desc,id desc')->limit(10)->select();
            $this->assign('data',$data);
            $type =1;
            $next_data= Db::name('hxzp')->where('is_del=0 and is_show=1 and sign="mobile"')->page(2,10)->select();
            if(!$next_data){
                $type =2;
            }
            $this->assign('type',$type);
            $this->assign('data_seo',getColumnseo(5));
            return $this->fetch();
        }

        public function nr(){
            $id = intval(input('param.id'));
            if($id){
                $data = Db::name('hxzp')->where('id',$id)->find();
                if($data['works_photo'] !==''){
                    $imgurl = Db::name('works_pic')->where('pic_id','in',$data['works_photo'])->select();
                    $data['imgurl']=$imgurl;
                }
                //上一组
                $upId = Db::name('hxzp')->where('id','<',$id)->where('is_del=0 and is_show=1 and sign="mobile"')->order('id desc')->limit(1)->value('id');
                $this->assign('upId',$upId);
                //下一组
                $downId = Db::name('hxzp')->where('id','>',$id)->where('is_del=0 and is_show=1 and sign="mobile"')->order('id asc')->limit(1)->value('id');
                $this->assign('downId',$downId);
                $this->assign('data',$data);
            }

            return $this->fetch();
        }

        public function getMore(){
            $page = intval(input('page'));
            $type =1;
            $res= Db::name('hxzp')->where('is_del=0 and is_show=1 and sign="mobile"')->page($page,10)->select();
            $next_data= Db::name('hxzp')->where('is_del=0 and is_show=1 and sign="mobile"')->page($page+1,10)->select();
            if(!$next_data){
                $type =2;
            }
            if($res){
                return json(['code'=>1,'data'=>$res,'type'=>$type]);
            }else{
                return json(['code'=>0,'msg'=>'没有更多了']);
            }

        }
}